package voxietest1.jam;

public class Paddle {
	public float x;
	public float y;
	public float z;
	public float width;
	public float height;
	public float origWidth;
	public float origHeight;
	public World world;
	
	public Paddle(World ww, float xx, float yy, float zz) {
		x = xx;
		y = yy;
		z = zz;
		world = ww;
		origWidth = .7f;
		origHeight = .7f;
		width = origWidth;
		height = origHeight;
	}
	
	public void resetSize() {
		width = origWidth;
		height = origHeight;
	}
	
	public void shrinkSize() {
		width *= .95f;
		height *= .95f;
	}
	
	boolean isInPaddle(float testx, float testy) {
		if (   (testx >= x-width*.55f && testx <= x+width*.55f)
			&& (testy >= y-height*.55f && testy <= y+height*.55f)) {
			
			return true;
		} else {
			return false;
		}
	}
	public void MoveTo(float xx, float yy, float zz) {
		x = xx;
		y = yy;
		z = zz;
		Update(0);
	}

	public void MoveTo(float xx, float yy) {
		x = xx;
		y = yy;
		Update(0);
	}

	public void Move(float dx, float dy) {
		x += dx;
		y += dy;
		Update(0);
	}
	
	public void Update(float deltaTime) {
		if (z < world.zmin) {
			z = world.zmin;
		}
		
		if (z > world.zmax) {
			z = world.zmax;
		}
		
		if (x-width/2 < world.xmin) {
			x = world.xmin+width/2;
		}
		if (x+width/2 > world.xmax) {
			x = world.xmax-width/2;
		}
		if (y-height/2 < world.ymin) {
			y = world.ymin+height/2;
		}
		if (y+height/2 > world.ymax) {
			y = world.ymax-height/2;
		}
		
	}

}
